package com.hongyi.common.framework.domain;

import com.hongyi.common.framework.constant.Constants;
import com.hongyi.common.framework.constant.UserConstans;
import com.hongyi.common.framework.validate.PasswordAuthGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import java.io.Serializable;


/**
 * 用户登录对象
 *
 * @author DingHao
 */
@Data
@ApiModel("用户登录对象")
public class LoginBody implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 用户类型
     */
    @NotBlank(message = "用户类型未设置",groups = {PasswordAuthGroup.class})
    @ApiModelProperty(name = "用户类型", value = "登录用户类型",required = true ,example = "sys_user")
    private String grantType;

    /**
     * 用户类型
     */
    @NotBlank(message = "设备类型未设置",groups = {PasswordAuthGroup.class})
    @ApiModelProperty(name = "设备类型", value = "登录设备类型",required = true ,example = "pc")
    private String deviceType;

    /**
     * 用户名
     */
    @NotBlank(message = "未输入用户名",groups = {PasswordAuthGroup.class})
    @Length(min = UserConstans.USERNAME_MIN_LENGTH, max = UserConstans.USERNAME_MAX_LENGTH, message = "用户名长度异常",groups = {PasswordAuthGroup.class})
    @ApiModelProperty(name = "用户名", value = "登录用户名",required = true, example = "user")
    private String username;

    /**
     * 用户密码
     */
    @NotBlank(message = "未输入密码",groups = {PasswordAuthGroup.class})
    @Length(min = UserConstans.PASSWORD_MIN_LENGTH, max = UserConstans.PASSWORD_MAX_LENGTH, message = "密码长度异常",groups = {PasswordAuthGroup.class})
    //@Pattern(regexp = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)[a-zA-Z\\d]+$", message = "密码必须包含大小写字母及数字", groups = {PasswordAuthGroup.class})
    @ApiModelProperty(name = "用户密码", value = "登录密码",required = true, example = "****")
    private String password;

    /**
     * 验证码
     */
    @NotBlank(message = "未输入验证码",groups = {PasswordAuthGroup.class})
    @ApiModelProperty(name = "验证码", value = "用户填写的验证码",required = true, example = "7")
    private String code;

    /**
     * 唯一标识
     */
    @ApiModelProperty(name = "唯一标识", value = "用于校验验证码的唯一标识",required = true, example = "84b2b973077d47b6b67e5ed6bf84531a")
    private String uuid;

}
